import { getNetworkSelect } from '@/api/network'
import { NetowrkOptional } from '@/components/pages/order/list/assign-network/types'
import { ref } from 'vue'

const networkOptions = ref<Array<NetowrkOptional>>([])
const getNetworkOptionsLoading = ref(false)
const getNetworkOptionsParam = ref({
  area: '',
  city: '',
  limit: 0,
  name: '',
  page: 0,
  province: '',
  type: 0,
  typeId: null,
})

const getNetworkOptions = async () => {
  getNetworkOptionsLoading.value = true
  const res = await getNetworkSelect(getNetworkOptionsParam.value)
  networkOptions.value = res.data.success ? res.data.data.rows : []
  getNetworkOptionsLoading.value = false
}

export default {
  networkOptions,
  getNetworkOptionsParam,
  getNetworkOptionsLoading,
  getNetworkOptions,
}
